package com.example.MyThread.ThreadTest04;

/**
 * @author Jason
 * @PACKAGE_NAME com.example.MyThread.ThreadTest04
 * @Description 常见的线程方法
 * @date 2023-12-10 19:30
 */
public class ThreadDemo {
    /**
     * 1. String getName()    返回此线程名称
     * 2. String setName()    设置线程名字（构造方法也可以设置名字）
     * 3. static Thread currentThread()    获取当前线程对象
     * 4. static void sleep(long time)    让线程休眠指定时间；单位：毫秒
     * 5. setPriority(int newPriority)    设置线程优先级
     * 6. final int getPriority()    获取线程优先级
     * 7. final void setDarmon(boolean on)    设置为守护线程
     * 8. public static void yield()    出让线程/礼让线程
     * 9. public static void join()    插入线程/插队线程
     */

    public static void main(String[] args) throws InterruptedException {
        MyThread t1 = new MyThread("线程1");
        MyThread t2 = new MyThread("线程2");

        //设置优先级
        t1.setPriority(1);
        t2.setPriority(5);

        t1.start();
        t2.start();
//        System.out.println(t1.getPriority());
//        System.out.println(t2.getPriority());
//        System.out.println(111);
//        Thread.sleep(5000);
//        System.out.println(222);
    }
}
